home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Magazin/MacEasy 52
/
Mac Magazin and MacEasy Magazine CD - Issue 52.iso
/
Updates
/
Stata 5.0 Ado-files
/
ado.sea
/
newado
/
svy_dreg.ado
< prev
next >
Wrap
Text File
|
1998-11-22
|
12KB
|
447 lines
*! version 1.2.1 31oct1997
program define svy_dreg /* display results */
version 5.0
if "$S_E_cmd"=="svylogit" { local or "OR" }
else if "$S_E_cmd"=="svymlog" { local rrr "RRr" }
local options /*
*/ "Level(int $S_level) Prob CI DEFF DEFT MEFF MEFT noHEADer `or' `rrr'"
parse "`*'"
if "`meff'`meft'"!="" {
capture di matrix(S_E_meft[1,1])
if _rc {
di in red "meff and meft options must be specified " /*
*/ "at initial estimation"
exit 198
}
}
if `level' < 10 | `level' > 99 {
local level 95
}
if "`prob'`ci'`deff'`deft'`meff'`meft'"=="" {
local prob "prob"
local ci "ci"
}
local count 2
if "`prob'"!="" {
local PROB " "
local count 3
}
else local PROB "*"
if "`ci'"!="" {
local CI " "
local count = `count' + 2
}
else local CI "*"
if "`deff'"!="" & `count' < 5 {
local deff
local DEFF " "
local count = `count' + 1
}
else local DEFF "*"
if "`deft'"!="" & `count' < 5 {
local deft
local DEFT " "
local count = `count' + 1
}
else local DEFT "*"
if "`meff'"!="" & `count' < 5 {
local meff
local MEFF " "
local count = `count' + 1
}
else local MEFF "*"
if "`meft'"!="" & `count' < 5 {
local meft
local MEFT " "
local count = `count' + 1
}
else local MEFT "*"
/* Get estimates. */
tempname t b V
scalar `t' = invt($S_E_npsu - $S_E_nstr, `level'/100)
matrix `b' = get(_b)
matrix `V' = get(VCE)
local dim = colsof(`b')
/* Odds ratio. */
if "`or'"!="" {
if `dim'==colnumb(`b',"_cons") {
local dim = `dim' - 1
}
}
else if "`rrr'"!="" { local or rrr }
else local or "no" /* make it nonmissing for argument passing */
/* Print out header. */
if "`header'"=="" { Header }
/* Print out column headers of table 1. */
DashLine
Colhead `level' `or' " " "`PROB'" "`CI'" /*
*/ "`DEFF'" "`DEFT'" "`MEFF'" "`MEFT'"
/* Print out body of table 1. */
DashLine 10
local i 1
while `i' <= `dim' {
Body `i' `b' `V' `t' `or' " " "`PROB'" "`CI'" /*
*/ "`DEFF'" "`DEFT'" "`MEFF'" "`MEFT'"
local i = `i' + 1
}
DashLine
/* See if there is more to print out. */
if "`deff'`deft'`meff'`meft'"=="" {
FootNote
exit
}
/* If here, we need to print out another table. */
if "`deff'"!="" { local DEFF " " }
else local DEFF "*"
if "`deft'"!="" { local DEFT " " }
else local DEFT "*"
if "`meff'"!="" { local MEFF " " }
else local MEFF "*"
if "`meft'"!="" { local MEFT " " }
else local MEFT "*"
if "`obs'"!="" { local OBS " " }
else local OBS "*"
if "`size'"!="" { local SIZE " " }
else local SIZE "*"
/* Print out column headers of table 2. */
DashLine
Colhead `level' `or' * * * "`DEFF'" "`DEFT'" "`MEFF'" "`MEFT'"
/* Print out body of table 2. */
DashLine 10
local i 1
while `i' <= `dim' {
Body `i' `b' `V' `t' `or' * * * /*
*/ "`DEFF'" "`DEFT'" "`MEFF'" "`MEFT'"
local i = `i' + 1
}
DashLine
FootNote
end
program define DashLine
if "`1'"=="" {
di in gr _dup(78) "-"
exit
}
local dash1 = `1' - 1
local dash2 = 78 - `1'
di in gr _dup(`dash1') "-" "+" _dup(`dash2') "-"
end
program define FootNote
if "$S_E_cmd"=="svymlog" & "$S_E_base"!="" {
di in blu "(Outcome $S_E_depv==$S_E_base is the " /*
*/ "comparison group)"
if "$S_E_fpc"!="" { di /* newline */ }
}
if "$S_E_fpc"!="" { /* print FPC note */
#delimit ;
di in blu "Finite population correction (FPC) assumes "
"simple random sampling without " _n
"replacement of PSUs within each stratum with no "
"subsampling within PSUs." ;
#delimit cr
}
if "$S_E_fail$S_E_succ"!="" {
if "$S_E_fail"!="" { local nfail "$S_E_fail" }
else local nfail 0
if "$S_E_succ"!="" { local nsucc "$S_E_succ" }
else local nsucc 0
if `nfail'==1 { local failure "failure" }
else local failure "failures"
if `nsucc'==1 { local success "success" }
else local success "successes"
di _n in blu "Note: `nfail' `failure' and `nsucc' " /*
*/ "`success' completely determined."
}
end
program define Colhead
local level "`1'"
local or "`2'"
macro shift 2
if "$S_E_cmd"=="svymean" | "$S_E_cmd"=="svyratio" /*
*/ | "$S_E_cmd"=="svytotal" {
local col1 " Estimate"
}
else if "`or'"=="or" { local col1 "Odds Ratio" }
else if "`or'"=="rrr" { local col1 " RRR" }
else local col1 " Coef."
`1' local head " `col1' Std. Err."
`2' local head "`head' t P>|t| "
`2' local s " "
`3' local head "`head'`s' [`level'% Conf. Interval]"
`3' local s " "
`4' local head "`head'`s' Deff"
`4' local s " "
`5' local head "`head'`s' Deft"
`5' local s " "
`6' local head "`head'`s' Meff"
`6' local s " "
`7' local head "`head'`s' Meft"
local col = 9 - length("$S_E_depv")
di in gr _col(`col') "$S_E_depv |" "`head'"
end
program define Body
local i "`1'"
local b "`2'"
local V "`3'"
local t "`4'"
local or "`5'"
macro shift 5
local s 2
tempname v
local colname : colnames(`b')
local coli : word `i' of `colname'
if "$S_E_cmd"=="svymlog" {
if "`or'"=="rrr" & "`coli'"=="_cons" { exit }
local eqlen = colsof(`b')/($S_E_ncat-1)
if `eqlen'==1 | mod(`i',`eqlen')==1 {
if `i' > 1 { DashLine 10 }
tempname A
matrix `A' = `b'[1,`i']
local eqname : coleq(`A')
di in ye "`eqname'" _col(10) in gr "|"
}
}
else if "$S_E_cmd"=="svyolog" | "$S_E_cmd"=="svyoprob" {
local icut = `i' - colsof(`b') + $S_E_ncat - 1
if `icut' >= 1 {
if `icut' == 1 { DashLine 10 }
local coli "_cut`icut'"
}
}
local col = 9 - length("`coli'")
di in gr _col(`col') "`coli' |" _c
if `V'[`i',`i']==0 {
if `b'[1,`i']==0 {
di in ye " (dropped)"
exit
}
scalar `v' = .
}
else scalar `v' = `V'[`i',`i']
if "`or'"!="no" {
local exp "exp"
local eb "exp(`b'[1,`i'])*"
}
`1' local body : di _s(2) %9.0g `exp'(`b'[1,`i']) _s(3) %9.0g /*
*/ `eb'sqrt(`v')
`1' local s 3
`2' local x : di _s(3) %8.3f `b'[1,`i']/sqrt(`v') /*
*/ %8.3f tprob($S_E_npsu-$S_E_nstr,`b'[1,`i']/sqrt(`v')) _s(2)
`2' local body "`body'`x'"
`3' local x : di _s(3) %9.0g `exp'(`b'[1,`i']-`t'*sqrt(`v')) /*
*/ _s(3) %9.0g `exp'(`b'[1,`i']+`t'*sqrt(`v'))
`3' local body "`body'`x'"
`4' local x : di _s(`s') %9.0g cond(S_E_deff[1,`i']!=0, /*
*/ S_E_deff[1,`i'],.)
`4' local body "`body'`x'"
`4' local s 3
`5' local x : di _s(`s') %9.0g cond(S_E_deft[1,`i']!=0, /*
*/ S_E_deft[1,`i'],.)
`5' local body "`body'`x'"
`5' local s 3
`6' local x : di _s(`s') %9.0g cond(S_E_meft[1,`i']!=0, /*
*/ S_E_meft[1,`i']^2,.)
`6' local body "`body'`x'"
`6' local s 3
`7' local x : di _s(`s') %9.0g cond(S_E_meft[1,`i']!=0, /*
*/ S_E_meft[1,`i'],.)
`7' local body "`body'`x'"
`7' local s 3
di in ye "`body'"
end
program define Header /* display header */
local wgt "$S_E_wgt"
local exp "$S_E_exp"
local strata "$S_E_str"
local psu "$S_E_psu"
if "`wgt'" == "" { local wgt "pweight" }
if "`exp'" == "" { local exp "<none>" }
if "`strata'" == "" { local strata "<one>" }
if "`psu'" == "" { local psu "<observations>" }
/* Set denominator df for F statistic and other stuff for F display. */
if "$S_E_adj"=="" { /* adjusted (default) */
local df = $S_E_npsu - $S_E_nstr - $S_E_mdf + 1
}
else local df = $S_E_npsu - $S_E_nstr
if $S_E_f >= 10000 { local fmtf "g" }
else local fmtf "f"
/* Set up display for subpop() option obs and size. */
if "$S_E_osub"!="" {
if "$S_E_fpc"=="" & "$S_E_r2"=="" { /* print up one line */
local left5a "Subpopulation no. of obs = "
local left5b : di %9.0f $S_E_osub
local left6a "Subpopulation size ="
local left6b : di %10.0g $S_E_nsub
}
else {
local left6a "Subpopulation no. of obs = "
local left6b : di %9.0f $S_E_osub
local left7a "Subpopulation size ="
local left7b : di %10.0g $S_E_nsub
}
}
/* Set up display for R-squared. */
if "$S_E_r2"!="" {
local right7a "R-squared = "
local right7b : di %9.4f $S_E_r2
}
/* Title. */
if "$S_E_cmd"=="svyreg" {
di _n in gr "Survey linear regression" _n
}
else if "$S_E_cmd"=="svylogit" {
di _n in gr "Survey logistic regression" _n
}
else if "$S_E_cmd"=="svyprobt" {
di _n in gr "Survey probit regression" _n
}
else if "$S_E_cmd"=="svyolog" {
di _n in gr "Survey ordered logistic regression" _n
}
else if "$S_E_cmd"=="svyoprob" {
di _n in gr "Survey ordered probit regression" _n
}
else if "$S_E_cmd"=="svymlog" {
di _n in gr "Survey multinomial logistic regression" _n
}
/* Note: _rmcoll (not used by svyreg, svylogit, svyprobt)
in svy_preg.ado always prints out a blank line.
*/
/* Print lines 1-4 (see notes at end of file). */
#delimit ;
di in gr "`wgt': `exp'"
in gr _col(51) "Number of obs" _col(68) "= "
in ye %9.0f $S_E_nobs _n
in gr "Strata: `strata'"
in gr _col(51) "Number of strata" _col(68) "= "
in ye %9.0f $S_E_nstr _n
in gr "PSU: `psu'"
in gr _col(51) "Number of PSUs" _col(68) "= "
in ye %9.0f $S_E_npsu ;
if "$S_E_fpc"!="" {
di in gr "FPC: $S_E_fpc"
in gr _col(51) "Population size" _col(68) "="
in ye %10.0g $S_E_npop
} ;
else di in gr _col(51) "Population size" _col(68) "="
in ye %10.0g $S_E_npop ;
/* Print lines 5-7 (see notes at end of file). */
di in gr "`left5a'" in ye "`left5b'"
in gr _col(51) "F(" in ye %4.0f $S_E_mdf in gr ","
in ye %7.0f `df' in gr ")" _col(68) "= "
in ye %9.2`fmtf' $S_E_f _n
in gr "`left6a'" in ye "`left6b'"
in gr _col(51) "Prob > F" _col(68) "= "
in ye %9.4f fprob($S_E_mdf,`df',$S_E_f) ;
if "`left7a'`right7a'"!="" { ;
di in gr "`left7a'" in ye "`left7b'"
in gr _col(51) "`right7a'" in ye "`right7b'" ;
} ;
di ;
end ;
exit ;
There are 4 possible arrangements for the header:
------------------------------------------------------------------------------
pweight: weight Number of obs = 21
Strata: strata Number of strata = 4
PSU: psu Number of PSUs = 14
FPC: Nh Population size = 189
F( 2, 9) = 3.43
Subpopulation no. of obs = 8 Prob > F = 0.0780
Subpopulation size = 82 R-squared = 0.4129
------------------------------------------------------------------------------
pweight: weight Number of obs = 21
Strata: strata Number of strata = 4
PSU: psu Number of PSUs = 14
Population size = 189
F( 2, 9) = 3.11
Subpopulation no. of obs = 8 Prob > F = 0.0937
Subpopulation size = 82 R-squared = 0.4129
------------------------------------------------------------------------------
pweight: weight Number of obs = 21
Strata: strata Number of strata = 4
PSU: psu Number of PSUs = 14
FPC: Nh Population size = 189
F( 2, 9) = 3.43
Subpopulation no. of obs = 8 Prob > F = 0.0780
Subpopulation size = 82
------------------------------------------------------------------------------
pweight: weight Number of obs = 21
Strata: strata Number of strata = 4
PSU: psu Number of PSUs = 14
Population size = 189
Subpopulation no. of obs = 8 F( 2, 9) = 3.11
Subpopulation size = 82 Prob > F = 0.0937
------------------------------------------------------------------------------
<end of file>